package edu.umd.ion.wavemeter.server;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import edu.umd.ion.wavemeter.service.ChannelInfo;

@SuppressWarnings("serial")
@Entity(name = "ChannelInfo")
@Table(name = "ChannelInfo") //Name of the entity
@NamedQueries({
    @NamedQuery(name="AllChannelInfo",
        query="SELECT x FROM ChannelInfo x")
})
public class PersistentChannelInfo implements Serializable, PersistentObject<Integer, PersistentChannelInfo> {
	@Id
	protected Integer Channel;
	protected String Name;
	protected Date LastSeen;
	public int getChannel() {
		return Channel;
	}
	public void setChannel(int channel) {
		Channel = channel;
	}
	public String getName() {
		return new String(Name);
	}
	public void setName(String name) {
		Name = name;
	}
	public Date getLastSeen() {
		return new Date(LastSeen.getTime());
	}
	public void setLastSeen(Date lastSeen) {
		LastSeen = lastSeen;
	}
	
	public ChannelInfo plain() {
		ChannelInfo c = new ChannelInfo();
		c.Name = new String(Name);
		c.Channel = Channel;
		c.LastSeen = new Date(LastSeen.getTime());
		return c;
	}
	
	public void set(ChannelInfo I) {
		Name = I.Name;
		LastSeen = I.LastSeen;
		Channel = I.Channel;
	}

	public void set(PersistentChannelInfo I) {
		Name = I.Name;
		LastSeen = I.LastSeen;
		Channel = I.Channel;
	}
	@Override
	public Integer getPrimaryKey() {
		return Channel;
	}
}
